export default function registerUser1(lf) {
  lf.register('user1', ({ PolygonNode, PolygonNodeModel, h }) => {
    class Node extends PolygonNode {
      getLabelShape() {
        console.log('this.props.model', this.props.model)
        const { x, y } = this.props.model
        return h(
          'text',
          {
            fill: '#000000',
            fontSize: 12,
            x: x - 13,
            y: y + 4,
            width: 50,
            height: 25,
          },
          '机床'
        )
      }

      getShape() {
        const { model } = this.props
        const { x, y } = model
        const style = model.getNodeStyle()
        return h('g', {}, [
          h('circle', {
            ...style,
            cx: x,
            cy: y,
          }),
          this.getLabelShape(),
        ])
      }
    }

    class Model extends PolygonNodeModel {
      constructor(data, graphModel) {
        data.text = {
          value: (data.text && data.text.value) || '',
          x: data.x,
          y: data.y + 50,
        }
        super(data, graphModel)
        const lenght = 35
        this.points = [
          [lenght, 0],
          [lenght * 2, lenght],
          [lenght, lenght * 2],
          [0, lenght],
        ]
        // 右键菜单自由配置，也可以通过边的properties或者其他属性条件更换不同菜单
        this.menu = [
          {
            text: '删除',
            className: 'lf-menu-delete',
            icon: true,
            callback(node) {
              const comfirm = window.confirm('你确定要删除吗？')
              comfirm && lf.deleteNode(node.id)
            },
          },
          {
            text: '编辑',
            className: 'lf-menu-item',
            callback(node) {
              lf.editText(node.id)
            },
          },
          {
            text: '复制',
            className: 'lf-menu-item',
            callback(node) {
              lf.cloneNode(node.id)
            },
          },
        ]
      }
    }

    return {
      view: Node,
      model: Model,
    }
  })
}
